/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package caintra.Sapra.ComponentsImplements;

import java.util.Locale;
import java.util.ResourceBundle;
import nextapp.echo2.app.Alignment;
import nextapp.echo2.app.Border;
import nextapp.echo2.app.Button;
import nextapp.echo2.app.Color;
import nextapp.echo2.app.Extent;
import nextapp.echo2.app.FillImage;
import nextapp.echo2.app.Font;
import nextapp.echo2.app.ImageReference;
import nextapp.echo2.app.ResourceImageReference;




/**
 *
 * @author Administrador
 */

public class BotonCaintra extends Button{

    public ResourceBundle bundle = ResourceBundle.getBundle("caintra.Sapra.Internacional.MessageBundle",Locale.US);


    public BotonCaintra(Color Back,Color fore) {
        super();
        setText("Prueba");
        setStyle(new BotonStyle(Back, fore));
        setWidth(new Extent(200, Extent.PX));
        setBorder(new  Border(new Extent(2, Extent.PX), Color.BLACK, 1));
        setTextPosition(Alignment.ALIGN_CENTER);
        setFont(new Font(Font.TIMES_NEW_ROMAN, 1, new Extent(10,Extent.PX)));
        setRolloverEnabled(true);
        setRolloverBackground(Color.YELLOW);
        setRolloverForeground(Color.BLACK);
        setPressedEnabled(true);
        setPressedBackground(Color.PINK);
        setPressedForeground(Color.BLACK);

    }
    public BotonCaintra(int width){
        setWidth(new Extent(width,Extent.PX));
    }
    public BotonCaintra(String img,String command){
        ImageReference image=new ResourceImageReference("org/sapra/echo/image/"+img);
        try {
            this.setWidth(new Extent(130));
            this.setHeight(new Extent(20));
            this.setIcon(image);
            this.setActionCommand(command);
        } catch (Exception e) {
        }
    }
    public BotonCaintra(String img,String command,int width,int height){
        ImageReference image=new ResourceImageReference("org/sapra/echo/image/"+img);
        try {
            this.setWidth(new Extent(width));
            this.setHeight(new Extent(height));
            this.setIcon(image);
            this.setActionCommand(command);
        } catch (Exception e) {
        }
    }

    public BotonCaintra(String title,int width,String command){

        try {

            if(bundle.containsKey(title.trim())){
                this.setText(bundle.getString(title.trim()));
            }else{
                this.setText(title);
            }
            this.setActionCommand(command);
            this.setWidth(new Extent(width, Extent.PX));
            this.setBorder(new  Border(2, Color.BLACK, Border.STYLE_GROOVE));
            this.setTextPosition(Alignment.ALIGN_CENTER);this.setAlignment(Alignment.ALIGN_CENTER);
            this.setFont(new Font(Font.TIMES_NEW_ROMAN, Font.BOLD, new Extent(10,Extent.PX)));
            this.setBackground(new Color(206, 204, 204));
            this.setRolloverEnabled(true);
            this.setRolloverBackground(new Color(43, 91, 225));
            this.setRolloverForeground(Color.WHITE);
            this.setPressedEnabled(true);
            this.setPressedBackground(new Color(254,185,132));
            this.setPressedForeground(Color.BLACK);

        } catch (Exception e) {
            this.setText(title);
        }




    }


}
